
const obj = {
  b: {
    cs1: [
      { d: 1 },
      { d: 2 }
    ],
    cs2: [
      { d: 3 },
      { d: 4 }
    ]
  }
};


function GetValueByJsonPath(obj: any, path: string) {
  let val = path.replace(/\[(\S)\]/g, '.$1');
  const keyArr = val.split('.');
  let resObj = obj;
  keyArr.forEach((v, i) => {
    if (i > 0) {
      resObj = resObj[v];
    }
  });
  return resObj;

}

console.log(GetValueByJsonPath(obj, 'obj.b.cs1[0].d'));
